package com.lrkj.payfee.controller;

import com.lrkj.common.utils.SecurityUtils;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;
import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lrkj.common.annotation.Log;
import com.lrkj.common.core.controller.BaseController;
import com.lrkj.common.core.domain.AjaxResult;
import com.lrkj.common.enums.BusinessType;
import com.lrkj.payfee.domain.BalanceRefill;
import com.lrkj.payfee.service.IBalanceRefillService;
import com.lrkj.common.utils.poi.ExcelUtil;
import com.lrkj.common.core.page.TableDataInfo;

/**
 * 余额充值Controller
 *
 * @author yajun_ren
 * @date 2022-07-25
 */
@RestController
@RequestMapping("/payfee/balanceRefill")
@Api(tags = "余额充值")
public class BalanceRefillController extends BaseController
{
    @Autowired
    private IBalanceRefillService balanceRefillService;

    /**
     * 查询余额充值列表
     */
    @ApiOperation(value = "查询余额充值列表", notes = "查询余额充值列表")
    @PreAuthorize("@ss.hasPermi('payfee:balanceRefill:list')")
    @GetMapping("/list")
    public TableDataInfo list(BalanceRefill balanceRefill)
    {
        startPage();
        this.changeParameter(balanceRefill.getParams());
        List<BalanceRefill> list = balanceRefillService.selectBalanceRefillList(balanceRefill);
        return getDataTable(list);
    }

    /**
     * 导出余额充值列表
     */
	@ApiOperation(value = "导出余额充值列表", notes = "导出余额充值列表")
    @PreAuthorize("@ss.hasPermi('payfee:balanceRefill:export')")
    @Log(title = "余额充值", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BalanceRefill balanceRefill)
    {
        List<BalanceRefill> list = balanceRefillService.selectBalanceRefillList(balanceRefill);
        ExcelUtil<BalanceRefill> util = new ExcelUtil<BalanceRefill>(BalanceRefill.class);
        return util.exportExcel(list, "余额充值数据");
    }

    /**
     * 获取余额充值详细信息
     */
	@ApiOperation(value = "获取余额充值详细信息", notes = "获取余额充值详细信息")
    @PreAuthorize("@ss.hasPermi('payfee:balanceRefill:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(balanceRefillService.selectBalanceRefillById(id));
    }

    /**
     * 新增余额充值
     */
    @ApiOperation(value = "新增余额充值", notes = "新增余额充值")
    @PreAuthorize("@ss.hasPermi('payfee:balanceRefill:add')")
    @Log(title = "余额充值", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BalanceRefill balanceRefill)
    {
        balanceRefill.setCreateBy(SecurityUtils.getUsername());
        return toAjax(balanceRefillService.insertBalanceRefill(balanceRefill));
    }

    /**
     * 修改余额充值
     */
    @ApiOperation(value = "修改余额充值", notes = "修改余额充值")
    @PreAuthorize("@ss.hasPermi('payfee:balanceRefill:edit')")
    @Log(title = "余额充值", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BalanceRefill balanceRefill)
    {
        return toAjax(balanceRefillService.updateBalanceRefill(balanceRefill));
    }

    /**
     * 删除余额充值
     */
    @ApiOperation(value = "删除余额充值", notes = "删除余额充值")
    @PreAuthorize("@ss.hasPermi('payfee:balanceRefill:remove')")
    @Log(title = "余额充值", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(balanceRefillService.deleteBalanceRefillByIds(ids));
    }
}
